package com.bird.设计模式.创建型.原型模式;

import java.util.Objects;

/**
 * @data 2022/3/6 17:03
 * @author: bird
 * @description: 发送邮件和创建邮件的的历史记录
 */
public class Mail  implements Cloneable{

    private String name; // 邮件名称
    private String emailAddress;// 邮件地址
    private String content;// 邮件内容

    // 默认的构造器
    public Mail() {
        System.out.println("Mail Class Construct");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getEmailAddress() {
        return emailAddress;
    }

    public void setEmailAddress(String emailAddress) {
        this.emailAddress = emailAddress;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Mail mail = (Mail) o;
        return Objects.equals(name, mail.name) &&
                Objects.equals(emailAddress, mail.emailAddress) &&
                Objects.equals(content, mail.content);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, emailAddress, content);
    }

    @Override
    public String toString() {
        return "Mail{" +
                "name='" + name + '\'' +
                ", emailAddress='" + emailAddress + '\'' +
                ", content='" + content + '\'' +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        System.out.println("clone object Class Construct");
        return super.clone();
    }
}
